class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
  def weibo
    @user = User.find_by_connect_oauth(request.env["omniauth.auth"], current_user)
    if @user and @user.persisted? and @user.uid 
      sign_in_and_redirect @user, :event => :authentication 
      set_flash_message(:notice, :success, :kind => "weibo") if is_navigational_format?
    else
      session["devise.connect_data"] = request.env["omniauth.auth"]
      redirect_to new_user_registration_url
    end
  end

  def qq_connect
    @user = User.find_by_connect_oauth(request.env["omniauth.auth"], current_user)
    if @user and @user.persisted? and @user.uid 
      sign_in_and_redirect @user, :event => :authentication 
      set_flash_message(:notice, :success, :kind => "QQ Connect") if is_navigational_format?
    else
      session["devise.connect_data"] = request.env["omniauth.auth"]
      redirect_to new_user_registration_url
    end
  end
end
